package gov.nasa.anml.utility;


// mutable integers
// but using these as keys in a hashtable requires not changing the value
// i.e., be careful!
public class SimpleInteger implements SimpleObject<SimpleInteger> {

	public int v;

	public SimpleInteger() {
		v = 0;
	}

	public SimpleInteger(int v) {
		this.v = v;
	}

	public int hashCode() {
		return v;
	}

	public boolean equals(Object obj) {
		if (obj instanceof SimpleInteger
				&& v == ((SimpleInteger) obj).v)
			return true;
		return false;
	}
	
	public boolean equals(SimpleInteger obj) {
		if (v == obj.v)
			return true;
		return false;
	}
	
	public SimpleInteger clone() {
		try {
			return (SimpleInteger) super.clone();
		} catch (CloneNotSupportedException e) {
			// assert false;
		}
		return null;
	}

	public int compareTo(SimpleInteger o) {
		if (this == null || o == null)
			return 1;
		return v - o.v;
	}

	public int compareTo(SimpleObject<SimpleInteger> o) {
		SimpleInteger i = (SimpleInteger) o;
		if (this == null || i == null)
			return 1;
		return v - i.v;
	}

	public String toString() {
		return java.lang.Integer.toString(v);
	}

	public void assign(SimpleInteger c) {
		v = c.v;
	}
	
	public void assign(int v) {
		this.v = v;
	}

	public SimpleInteger value() {
		return this;
	}
}
